< previous page page_420 next page >

Page 420
which data formats the source control supports by setting the format argument in the OLEStartDrag event. The SetData method is used to set the format of the data. The code in Listing 15.1 sets the drag effects allowed to Copy and Move, and also assigns the data format of the DataObject to both text and richtext.
LISTING 15.1. STARTDRAG.TXTCUSTOMIZING THE START DRAG PROCESSING.

8694cbadb9b1ef7075903f6f95fc1db2.gif
1: Private Sub tvwBook_OLEStartDrag(Data As VB.DataObject, AllowedEffects _
   As Long)
2:     AllowedEffects = vbDropEffectMove Or vbDropEffectCopy
3:     Data.SetData , vbCFText
4:     Data.SetData , vbCFRTF
5: End Sub

Putting Data in Its Place
The DataObject usually has data placed in it at the beginning of a drag operation by executing the SetData method in the OLEStartDrag event as shown in Listing 15.2. This clears the default data formats from the DataObject, sets the current data format of the selected data, and then puts that data into the DataObject.
LISTING 15.2. SETDATA.TXTSETTING THE DATA FORMAT AND ASSIGNING THE DATA IN THEStartDrag EVENT.

8694cbadb9b1ef7075903f6f95fc1db2.gif
1: Private Sub tvwBook_OLEStartDrag(Data As VB.DataObject, AllowedEffects _
   As Long)
2:     Data.Clear
3:     Data.SetData tvwBook.SelText, vbCFText
4: End Sub

The OLEDragOver Event
The OLEDragOver event is triggered whenever you drag data over a control. The effect and state arguments of the OLEDragOver event are used to inform the program of the exact properties and status of the data being dragged. The effect argument is used to specify that action should be taken if the data is dropped. Whenever the value of the argument is changed, the source control's OLEGiveFeedback event will be triggered, which can then be used to provide the user with some type of visual feedback. The constants listed in Table 15.5 are used in conjunction with the effect argument to retrieve or set the effects allowed.

 
< previous page page_420 next page >

If you like this book, buy it!